import * as sdk from './fetch';

const controllerName = 'CustomerDeliveryAddressController';

/**
 *
 * 保存客户收货地址
 *
 */
async function saveAddress(editRequest: ISaveAddressEditRequestReq): Promise<unknown> {
  let result = await sdk.post(
    'customer/address',

    {
      ...editRequest,
    },
  );
  return result.context;
}

/**
 *
 * 根据地址id查询客户收货地址详情
 *
 */
async function findById(addressId: IFindByIdAddressIdReq): Promise<CustomerDeliveryAddressByIdResponse> {
  let result = await sdk.get<CustomerDeliveryAddressByIdResponse>(
    'customer/address/{addressId}'.replace('{addressId}', addressId + ''),

    {},
  );
  return result.context;
}


/**
 *
 * 修改客户收货地址
 *
 */
async function updateAddress(editRequest: IUpdateAddressEditRequestReq): Promise<unknown> {
  let result = await sdk.put(
    'customer/addressInfo',

    {
      ...editRequest,
    },
  );
  return result.context;
}

/**
 *
 * 设置客户收货地址为默认
 *
 */
async function setDefaultAddress(deliveryAddressId: IFindByIdAddressIdReq): Promise<unknown> {
  let result = await sdk.post(
    'customer/defaultAddress/{deliveryAddressId}'.replace('{deliveryAddressId}', deliveryAddressId + ''),

    {},
  );
  return result.context;
}

/**
 *
 * 删除客户收货地址
 *
 */
async function deleteAddress(addressId: IDeleteAddress_AddressIdReq): Promise<unknown> {
  let result = await sdk.deleteF(
    'customer/addressInfo/{addressId}'.replace('{addressId}', addressId + ''),

    {},
  );
  return result.context;
}

/**
 *
 * 查询该客户的所有收货地址
 *
 */
async function findAddressList(): Promise<CustomerDeliveryAddressVOArray> {
  let result = await sdk.get<CustomerDeliveryAddressVOArray>(
    'customer/addressList',

    {},
  );
  return result.context;
}


export default {
  saveAddress,

  findById,

  updateAddress,

  deleteAddress,

  findAddressList,

  setDefaultAddress,
};

/**
 * 内容
 */
export type CustomerDeliveryAddressVOArray = CustomerDeliveryAddressVO[];
/**
 * 地址id
 *
 * This interface was referenced by `IgnoreType`'s JSON-Schema
 * via the `definition` "IFindByIdAddressIdReq".
 */
export type IFindByIdAddressIdReq = string;
/**
 * 地址id
 *
 * This interface was referenced by `IgnoreType`'s JSON-Schema
 * via the `definition` "IDeleteAddress_AddressIdReq".
 */
export type IDeleteAddress_AddressIdReq = string;
/**
 * 内容
 */
export interface CustomerDeliveryAddressByIdResponse {
  /**
   * 区
   */
  areaId?: number;
  /**
   * 市
   */
  cityId?: number;
  /**
   * 收货人
   */
  consigneeName?: string;
  /**
   * 收货人手机号码
   */
  consigneeNumber?: string;
  /**
   * 创建人
   */
  createPerson?: string;
  /**
   * 创建时间
   */
  createTime?: string;
  /**
   * 客户ID
   */
  customerId?: string;
  /**
   * 删除标志
   * * NO: 否
   * * YES: 是
   */
  delFlag?: 0 | 1;
  /**
   * 删除人
   */
  deletePerson?: string;
  /**
   * 删除时间
   */
  deleteTime?: string;
  /**
   * 详细地址
   */
  deliveryAddress?: string;
  /**
   * 收货地址ID
   */
  deliveryAddressId?: string;
  /**
   * 是否是默认地址
   * * NO: 否
   * * YES: 是
   */
  isDefaltAddress?: 0 | 1;
  /**
   * 省
   */
  provinceId?: number;
  /**
   * 街道
   */
  streetId?: number;
  /**
   * 修改人
   */
  updatePerson?: string;
  /**
   * 修改时间
   */
  updateTime?: string;
  [k: string]: any;
}
export interface CustomerDeliveryAddressVO {
  /**
   * 区
   */
  areaId?: number;
  /**
   * 市
   */
  cityId?: number;
  /**
   * 收货人
   */
  consigneeName?: string;
  /**
   * 收货人手机号码
   */
  consigneeNumber?: string;
  /**
   * 创建人
   */
  createPerson?: string;
  /**
   * 创建时间
   */
  createTime?: string;
  /**
   * 客户ID
   */
  customerId?: string;
  /**
   * 删除标志
   * * NO: 否
   * * YES: 是
   */
  delFlag?: 0 | 1;
  /**
   * 删除人
   */
  deletePerson?: string;
  /**
   * 删除时间
   */
  deleteTime?: string;
  /**
   * 详细地址
   */
  deliveryAddress?: string;
  /**
   * 收货地址ID
   */
  deliveryAddressId?: string;
  /**
   * 是否是默认地址
   * * NO: 否
   * * YES: 是
   */
  isDefaltAddress?: 0 | 1;
  /**
   * 省
   */
  provinceId?: number;
  /**
   * 修改人
   */
  updatePerson?: string;
  /**
   * 修改时间
   */
  updateTime?: string;
  [k: string]: any;
}
/**
 * This interface was referenced by `IgnoreType`'s JSON-Schema
 * via the `definition` "ISaveAddressEditRequestReq".
 */
export interface ISaveAddressEditRequestReq {
  /**
   * 区
   */
  areaId?: number;
  /**
   * 市
   */
  cityId?: number;
  /**
   * 收货人
   */
  consigneeName?: string;
  /**
   * 收货人手机号码
   */
  consigneeNumber?: string;
  /**
   * 客户ID
   */
  customerId?: string;
  /**
   * 详细地址
   */
  deliveryAddress?: string;
  /**
   * 收货地址ID
   */
  deliveryAddressId?: string;
  /**
   * 操作人员id
   */
  employeeId?: string;
  /**
   * 是否默认地址
   * * NO: 否
   * * YES: 是
   */
  isDefaltAddress?: 0 | 1;
  /**
   * 省
   */
  provinceId?: number;
  /**
   * 街道
   */
  streetId?: number;
  [k: string]: any;
}
/**
 * This interface was referenced by `IgnoreType`'s JSON-Schema
 * via the `definition` "IUpdateAddressEditRequestReq".
 */
export interface IUpdateAddressEditRequestReq {
  /**
   * 区
   */
  areaId?: number;
  /**
   * 市
   */
  cityId?: number;
  /**
   * 收货人
   */
  consigneeName?: string;
  /**
   * 收货人手机号码
   */
  consigneeNumber?: string;
  /**
   * 客户ID
   */
  customerId?: string;
  /**
   * 详细地址
   */
  deliveryAddress?: string;
  /**
   * 收货地址ID
   */
  deliveryAddressId?: string;
  /**
   * 操作人员id
   */
  employeeId?: string;
  /**
   * 是否默认地址
   * * NO: 否
   * * YES: 是
   */
  isDefaltAddress?: 0 | 1;
  /**
   * 省
   */
  provinceId?: number;
  /**
   * 街道
   */
  streetId?: number;
  [k: string]: any;
}
//create by moon https://github.com/creasy2010/moon
